package phase1_testCase;

import static org.junit.Assert.*;
import java.util.*;
import org.junit.Before;
import org.junit.Test;
import phase1.FindByPath;
import phase1.Block;
public class FindByPath_testCase {

	@Before
	public void setUp() throws Exception {
	}

	//test with single path result should contain "aba","abb","aby"
	@Test
	public void testFindTheWords() {
		Block b1=new Block('a','a','a');
		Block b2=new Block('b','z','b');
		Block b3=new Block('a','b','y');
		b1.setNextBlock(b2);
		b2.setNextBlock(b3);
		FindByPath fbp=new FindByPath();
		Vector<String> test=new Vector<String>();
		Vector<String> expectedResult=new Vector<String>();
		
		expectedResult.add("aba");
		expectedResult.add("abb");
		expectedResult.add("aby");
		
		fbp.findTheWords(b1, "", test, 3);
		System.out.println(test);
		assertEquals(test,expectedResult);
	}
	
	//test with multiple path, result should contain "aba","abb","aby"
	@Test
	public void testFindTheWords_2() {
		Block b1=new Block('a','a','a');
		Block b2=new Block('b','z','b');
		Block b3=new Block('a','b','y');
		b1.setNextBlock(b2);
		b2.setNextBlock(b3);
		b1.setNextBlock(b3);	//add one more path
		FindByPath fbp=new FindByPath();
		Vector<String> test=new Vector<String>();
		Vector<String> expectedResult=new Vector<String>();
		
		expectedResult.add("aba");
		expectedResult.add("abb");
		expectedResult.add("aby");
		
		fbp.findTheWords(b1, "", test, 3);
		System.out.println(test);
		assertEquals(test,expectedResult);
	}

	//test with multiple complex path, result should contain "aba","abaft","abb","abba","abasia"
	@Test
	public void testFindTheWords_3() {
		Block b1=new Block();b1.addChar('a');
		Block b2=new Block();b2.addChar('b');b2.addChar('c');
		Block b3=new Block();b3.addChar('a');b3.addChar('b');
		Block b4=new Block();b4.addChar('f');b4.addChar('i');b4.addChar('a');
		Block b5=new Block();b5.addChar('t');b5.addChar('a');
		Block b6=new Block();b6.addChar('a');
		Block b7=new Block();b7.addChar('s');b7.addChar('t');

		b1.setNextBlock(b2);
		b2.setNextBlock(b3);
		b3.setNextBlock(b4);
		b4.setNextBlock(b5);
		b2.setNextBlock(b6);
		b6.setNextBlock(b7);
		b7.setNextBlock(b4);
		FindByPath fbp=new FindByPath();
		Vector<String> test=new Vector<String>();
		Vector<String> expectedResult=new Vector<String>();
		
		expectedResult.add("aba");
		expectedResult.add("abaft");
		expectedResult.add("abb");
		expectedResult.add("abba");
		expectedResult.add("abasia");
		
		fbp.findTheWords(b1, "", test, 7);
		System.out.println(test);
		assertEquals(test,expectedResult);
	}
}
